//
//  AXMyJfTableViewCell.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/10/17.
//  Copyright © 2018年 tzhg. All rights reserved.
//

#import "AXMyJfTableViewCell.h"

@interface AXMyJfTableViewCell ()

@end


@implementation AXMyJfTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self creatView];
        [self setlayout];
    }
    return self;
}


- (void)creatView {
    /** 产品图片 */
    self.productImageView = [[UIImageView alloc]init];
    /** 图片比例切 */
    self.productImageView.contentMode =UIViewContentModeScaleAspectFill;
    self.productImageView.clipsToBounds=YES;//
    self.productImageView.image = [UIImage imageNamed:@"tz.jpeg"];
    [self.contentView addSubview:self.productImageView];
    /** 产品名字 */
    self.productNameLabel = [[UILabel alloc]init];
    self.productNameLabel.text = @"优选水蜜桃";
    self.productNameLabel.textColor =COLOR_DIV ;
    self.productNameLabel.font = FONT_FOURTEEN;;
    [self.contentView addSubview:self.productNameLabel];
    /** 产品件数 */
    self.productCountLabel = [[UILabel alloc]init];
    self.productCountLabel.text = @"限量44件";
    self.productCountLabel.textColor = COLOR_GREEN;
    self.productCountLabel.font = FONT_FOURTEEN;;
    [self.contentView addSubview:self.productCountLabel];
    /** 积分 */
    self.integralLabel = [[UILabel alloc]init];
    self.integralLabel.text = @"520积分";
    self.integralLabel.font = FONT_FOURTEEN;;
    self.integralLabel.textColor = COLOR_ORG;
    [self.contentView addSubview:self.integralLabel];
    /** 价格*/
    self.priceLabel = [[UILabel alloc]init];
    self.priceLabel.text = @"99";
    self.priceLabel.font = FONT_FOURTEEN;;
    self.priceLabel.textColor = COLOR_ORG;
    [self.contentView addSubview:self.priceLabel];
    /**删除线 */
    self.deleteLineView = [[UIView alloc]init];
    self.deleteLineView.backgroundColor = COLOR_GREEN;
    [self.contentView addSubview:self.deleteLineView];
    /** 购物车*/
    self.shopCartButton = [[UIButton alloc]init];
    [self.shopCartButton setImage:[UIImage imageNamed:@"orgcar"] forState:UIControlStateNormal];
    [self.contentView addSubview:self.shopCartButton];
   
    
    
}

- (void)setlayout {
    
    /** 购物车*/
    self.shopCartButton.sd_layout
    .rightSpaceToView(self.contentView, 10)
    .bottomSpaceToView(self.contentView, 10)
    .widthIs(30)
    .heightIs(30);
    
    /** 产品图片 */
    self.productImageView.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 10)
    .widthIs(100)
    .heightIs(100);
    /** 产品名字 */
    self.productNameLabel.sd_layout
    .leftSpaceToView(self.productImageView, 10)
    .topSpaceToView(self.contentView, 10)
    .widthIs(100)
    .heightIs(30);
    /** 产品件数 */
    self.productCountLabel.sd_layout
    .leftSpaceToView(self.productImageView, 10)
    .topSpaceToView(self.productNameLabel, 0)
    .rightSpaceToView(self.shopCartButton, 10)
    .heightIs(30);
    /** 积分 */
    self.integralLabel.sd_layout
    .leftSpaceToView(self.productImageView, 10)
    .topSpaceToView(self.productCountLabel, 0)
    .widthIs(100)
    .heightIs(30);
    /** 价格*/
    self.priceLabel.sd_layout
    .leftSpaceToView(self.integralLabel, 10)
    .topSpaceToView(self.productCountLabel, 0)
    .widthIs(50)
    .heightIs(30);
    /**删除线 */
    self.deleteLineView.sd_layout
    .leftSpaceToView(self.integralLabel, -5)
    .centerYEqualToView(self.priceLabel)
    .widthRatioToView(self.priceLabel, 1)
    .heightIs(1);
    //cell 自适应第一步
    [self setupAutoHeightWithBottomView:self.integralLabel bottomMargin:10];
    
}

@end
